/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gac.ui;

import java.awt.Point;
import org.netbeans.api.visual.action.MoveStrategy;
import org.netbeans.api.visual.widget.Widget;

/**
 *
 * @author Tomek
 */
class MyMoveStrategy implements MoveStrategy
{

    private BoxScene _scene;

    public MyMoveStrategy(BoxScene scene)
    {
        _scene = scene;
    }

    public Point locationSuggested(Widget arg0, Point arg1, Point arg2)
    {
        //System.out.println( "__________________");
        Point absolutePt = (Point) arg1.clone();
        //System.out.println( "A1" + absolutePt );
        //absolutePt = arg0.convertLocalToScene(absolutePt);
        //System.out.println( "A2" + absolutePt );
        absolutePt.move(arg2.x, arg2.y);
        //System.out.println( "A3" + absolutePt );
        DropAreaWidget w = _scene.FindBestDropArea(arg0, absolutePt);
        //System.out.println("Modifying loc from: " + arg2 + " to " + absolutePt);
        if (w != null)
        {
            
            return arg2;//arg0.convertSceneToLocal(w.convertLocalToScene(w.getLocation()));
        } else
        {
            return arg2;
        }
    }
}
